import requests
class query:
    cookies = {
        'JSESSIONID': '16E734D652A39D12F0CDA98DD16442FF',
        'tempTokenKey': 'eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiLnhormr4UiLCJhdWQiOiI5RTEwNTlDOTMzNUQ0QzdDQjhEQzc0MDBEMDNBRUNGQiIsInNlcnZlciI6bnVsbCwicm9sZSI6IlJPTEVfQVJFQSxST0xFX1dJTkRPVyIsImlzSW5pdGlhbFBhc3N3b3JkIjoiMCIsInJlZ2lvbk5hbWUiOiLotLXlt57nnIEiLCJpbmR1c3RyeSI6bnVsbCwiYXBwQ29kZSI6ImRnb3YtcG9ydGFsIiwib3JnYW5OYW1lIjoi5LqR5LiK6LS15beeIiwicmVnaW9uQ29kZSI6IjUyMDAwMCIsImluZHVzdHJ5TGlzdCI6bnVsbCwib3JnYW5Db2RlIjoiNTIwMDAyIiwiZXhwaXJhdGlvblRpbWUiOjMyLCJncmFkZSI6IjIiLCJzdGF0dXMiOiIxIiwiaXNzIjoiaW5zcHVyIiwiaWF0IjoxNzIxODMwNTM4LCJleHAiOjE3MjE4NTkzMzh9.nfUyqL10JvoKGPJ3vb66xyuvRkonQ3cqmL0O2Y2itPQlbJTv8yfaNP68xvPs1ld4aHVQtfiHxlh8-_yqwaOiLw',
        'userInfoKey': '{^%^22role^%^22:^%^22ROLE_AREA^%^2CROLE_WINDOW^%^22^%^2C^%^22isInitialPassword^%^22:^%^220^%^22^%^2C^%^22regionName^%^22:^%^22^%^E8^%^B4^%^B5^%^E5^%^B7^%^9E^%^E7^%^9C^%^81^%^22^%^2C^%^22appCode^%^22:^%^22dgov-portal^%^22^%^2C^%^22organName^%^22:^%^22^%^E4^%^BA^%^91^%^E4^%^B8^%^8A^%^E8^%^B4^%^B5^%^E5^%^B7^%^9E^%^22^%^2C^%^22regionCode^%^22:^%^22520000^%^22^%^2C^%^22phone^%^22:^%^22384d53fa06a4844cfd54260b048c33e9^%^22^%^2C^%^22organCode^%^22:^%^22520002^%^22^%^2C^%^22expirationTime^%^22:32^%^2C^%^22name^%^22:^%^221342b48e6f8f39ea7ba36accc05b61a8^%^22^%^2C^%^22id^%^22:^%^229E1059C9335D4C7CB8DC7400D03AECFB^%^22^%^2C^%^22email^%^22:^%^22aa67c9bf293c42e9144476195b550c0f^%^22^%^2C^%^22username^%^22:^%^2247d57692a252657367001b6a2ff35333^%^22^%^2C^%^22status^%^22:^%^221^%^22^%^2C^%^22isWeakPwd^%^22:^%^220^%^22}',
        'pwdState': 'true',
        'inspurRoleKey': 'ROLE_AREA',
        'windowId': '0B7CA12E92004E0ABCA9EB88F0A792E4',
        'James_cookie_sYQDUGqqzHtheme': 'custom',
    }

    headers = {
        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:126.0) Gecko/20100101 Firefox/126.0',
        'Accept': 'application/json, text/javascript, */*; q=0.01',
        'Accept-Language': 'zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2',
        # 'Accept-Encoding': 'gzip, deflate',
        'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
        'X-Requested-With': 'XMLHttpRequest',
        'Origin': 'http://61.243.3.187:82',
        'Connection': 'keep-alive',
        'Referer': 'http://61.243.3.187:82/zhslzy/accept/monitor/allbusiness/index',
        # 'Cookie': 'JSESSIONID=16E734D652A39D12F0CDA98DD16442FF; tempTokenKey=eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiLnhormr4UiLCJhdWQiOiI5RTEwNTlDOTMzNUQ0QzdDQjhEQzc0MDBEMDNBRUNGQiIsInNlcnZlciI6bnVsbCwicm9sZSI6IlJPTEVfQVJFQSxST0xFX1dJTkRPVyIsImlzSW5pdGlhbFBhc3N3b3JkIjoiMCIsInJlZ2lvbk5hbWUiOiLotLXlt57nnIEiLCJpbmR1c3RyeSI6bnVsbCwiYXBwQ29kZSI6ImRnb3YtcG9ydGFsIiwib3JnYW5OYW1lIjoi5LqR5LiK6LS15beeIiwicmVnaW9uQ29kZSI6IjUyMDAwMCIsImluZHVzdHJ5TGlzdCI6bnVsbCwib3JnYW5Db2RlIjoiNTIwMDAyIiwiZXhwaXJhdGlvblRpbWUiOjMyLCJncmFkZSI6IjIiLCJzdGF0dXMiOiIxIiwiaXNzIjoiaW5zcHVyIiwiaWF0IjoxNzIxODMwNTM4LCJleHAiOjE3MjE4NTkzMzh9.nfUyqL10JvoKGPJ3vb66xyuvRkonQ3cqmL0O2Y2itPQlbJTv8yfaNP68xvPs1ld4aHVQtfiHxlh8-_yqwaOiLw; userInfoKey={^%^22role^%^22:^%^22ROLE_AREA^%^2CROLE_WINDOW^%^22^%^2C^%^22isInitialPassword^%^22:^%^220^%^22^%^2C^%^22regionName^%^22:^%^22^%^E8^%^B4^%^B5^%^E5^%^B7^%^9E^%^E7^%^9C^%^81^%^22^%^2C^%^22appCode^%^22:^%^22dgov-portal^%^22^%^2C^%^22organName^%^22:^%^22^%^E4^%^BA^%^91^%^E4^%^B8^%^8A^%^E8^%^B4^%^B5^%^E5^%^B7^%^9E^%^22^%^2C^%^22regionCode^%^22:^%^22520000^%^22^%^2C^%^22phone^%^22:^%^22384d53fa06a4844cfd54260b048c33e9^%^22^%^2C^%^22organCode^%^22:^%^22520002^%^22^%^2C^%^22expirationTime^%^22:32^%^2C^%^22name^%^22:^%^221342b48e6f8f39ea7ba36accc05b61a8^%^22^%^2C^%^22id^%^22:^%^229E1059C9335D4C7CB8DC7400D03AECFB^%^22^%^2C^%^22email^%^22:^%^22aa67c9bf293c42e9144476195b550c0f^%^22^%^2C^%^22username^%^22:^%^2247d57692a252657367001b6a2ff35333^%^22^%^2C^%^22status^%^22:^%^221^%^22^%^2C^%^22isWeakPwd^%^22:^%^220^%^22}; pwdState=true; inspurRoleKey=ROLE_AREA; windowId=0B7CA12E92004E0ABCA9EB88F0A792E4; James_cookie_sYQDUGqqzHtheme=custom',
        'Priority': 'u=1',
    }
    def query(self):
        list = ['樊文艳',
'唐维',
'杨瑛梓',
'张乙涵',
'朱玉叶',
'詹兴星',
'刘豪',
'贾玉洁',
'李洪梅',
'孙小松',
'姚晨晨',
'符艺淋',
'雷平星',
'母永利',
'王素',
'丁塑红',
'姚仕霞',
'杨小燕',
'李航丽',
'陈宇星',
'王维维',
'吴金燕',
'贾凌云',
'王树树',
'黄宇',
'陈婷',
'甘志清',
'韦小燕',
'张勤',
'岺继美',
'冯杰',
'简小丽',
'丁宇杰',
'彭霞',
'王红霞 ',
'杨艳',
'岳秀梅',
'黎静',
'郑继力',
'白露',
'姚凤',
'文静',
'罗传叶',
'张洁',
'宋紫玲',
'杨满',
'李应维',
'周骥',
'刘丽春',
'石娅',
'周显东',
'陈小兰',
'张玲娇',
'赵明书',
'郭韦玮',
'李碧雨',
'喻萍',
'宋晓艳',
'毛远兰',
'汪夕人',
'黄富琴',
'赵倩',
'陈小明',
'刘畅',
'熊世君',
'张文兰',
'邹登琴',
'余小兰',
'倪雪',
'张志颖',
'陈媛',
'卢涛',
'杨静',
'李天敏',
'陆龙红',
'符迁迁',
'周泽宇',
'付娜娜',
'冯鹏博',
'赵勋']
        list2 = []
        for i in list:
            params = {
                'isprivilege': '',
                'from': '',
                'isFastSearch': 'false',
                'jumpState': '',
            }
            import urllib.parse

            # 要编码的字符串
            original_string = i

            # 使用 quote 函数进行 URL 编码
            encoded_string = urllib.parse.quote(original_string)
            data='applicant=&applynum=&itemname={}&itemType=&receiveUser=&receiveTime=2024-07-22+%E8%87%B3+2024-07-28&receiveTime_start=2024-07-22&receiveTime_end=2024-07-28&acceptUser=&submitTime=&submitTime_start=&submitTime_end=&finishTime=&finishTime_start=&finishTime_end=&regName=&regCode=&regId=&orgName=&orgCode=&applySubject=&curState=&state=&applyFrom=&assort=&objectCertNo=&agentIdCard=&queryDepartment=0&serviceObject=&companyRegisterRegion=&isFinish=2&_search=true&nd=1721795214730&rows=10&page=1&sidx=FINISH_TIME+DESC%2C+RECEIVE_TIME+&sord=desc'.format(encoded_string).encode('utf8')
            response = requests.post(
                'http://61.243.3.187:82/zhslzy/accept/monitor/allbusiness/queryAll',
                params=params,
                cookies=self.cookies,
                headers=self.headers,
                data=data,
            ).json()


            for i in response['rows']:
                ITEM_NAME=i['cell']['ITEM_NAME']
                RECEIVE_NUMBER=i['cell']['RECEIVE_NUMBER']
                BSNUM=i['cell']['BSNUM']
                list2.append([urllib.parse.unquote(encoded_string, encoding='utf-8'),ITEM_NAME, RECEIVE_NUMBER, BSNUM])
        print(list2)
        return list2

    def save(self):


        import pandas as pd



        data=self.query()
        df = pd.DataFrame(data, columns=['姓名', '申请项目', '申请编号', '申请状态'])

        # 写入 Excel 文件
        df.to_excel('网申结果xxxxx.xlsx', index=False)

        print("数据写入 网申结果xxxx.xlsx 成功！")
query().save()
#query().query()